home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 1 / CU Amiga Magazine CD-ROM Special Edition (1995)(EMAP Images)(GB)[Issue 1995-11].iso / Aminet / comm / tcp / ATCP_sdk_40_gc.lha / AmiTCP-4.0-gcc / netinclude / netinet / in.h
C/C++ Source or Header  |  1995-06-04  |  5KB  |  174 lines

  1. /*
  2.  * Copyright (c) 1982, 1986 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that the above copyright notice and this paragraph are
  7.  * duplicated in all such forms and that any documentation,
  8.  * advertising materials, and other materials related to such
  9.  * distribution and use acknowledge that the software was developed
  10.  * by the University of California, Berkeley.  The name of the
  11.  * University may not be used to endorse or promote products derived
  12.  * from this software without specific prior written permission.
  13.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  14.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  15.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16.  *
  17.  *    @(#)in.h        7.6 (Berkeley) 6/29/88
  18.  */
  19.  
  20. #ifndef _NETINET_IN_H
  21. #define _NETINET_IN_H
  22. /*
  23.  * Constants and structures defined by the internet system,
  24.  * Per RFC 790, September 1981.
  25.  */
  26.  
  27. /*
  28.  * Protocols
  29.  */
  30. #define IPPROTO_IP        0        /* dummy for IP */
  31. #define IPPROTO_ICMP        1        /* control message protocol */
  32. #define IPPROTO_GGP        3        /* gateway^2 (deprecated) */
  33. #define IPPROTO_TCP        6        /* tcp */
  34. #define IPPROTO_EGP        8        /* exterior gateway protocol */
  35. #define IPPROTO_PUP        12        /* pup */
  36. #define IPPROTO_UDP        17        /* user datagram protocol */
  37. #define IPPROTO_IDP        22        /* xns idp */
  38.  
  39. #define IPPROTO_RAW        255        /* raw IP packet */
  40. #define IPPROTO_MAX        256
  41.  
  42.  
  43. /*
  44.  * Ports < IPPORT_RESERVED are reserved for
  45.  * privileged processes (e.g. root).
  46.  * Ports > IPPORT_USERRESERVED are reserved
  47.  * for servers, not necessarily privileged.
  48.  */
  49. #define IPPORT_RESERVED     1024
  50. #define IPPORT_USERRESERVED    5000
  51.  
  52. /*
  53.  * Link numbers
  54.  */
  55. #define IMPLINK_IP        155
  56. #define IMPLINK_LOWEXPER    156
  57. #define IMPLINK_HIGHEXPER    158
  58.  
  59. /*
  60.  * Internet address (a structure for historical reasons)
  61.  */
  62. struct in_addr {
  63.     u_long s_addr;
  64. };
  65.  
  66. /*
  67.  * Definitions of bits in internet address integers.
  68.  * On subnets, the decomposition of addresses to host and net parts
  69.  * is done according to subnet mask, not the masks here.
  70.  */
  71. #define IN_CLASSA(i)            (((long)(i) & 0x80000000) == 0)
  72. #define IN_CLASSA_NET        0xff000000
  73. #define IN_CLASSA_NSHIFT    24
  74. #define IN_CLASSA_HOST        0x00ffffff
  75. #define IN_CLASSA_MAX        128
  76.  
  77. #define IN_CLASSB(i)            (((long)(i) & 0xc0000000) == 0x80000000)
  78. #define IN_CLASSB_NET        0xffff0000
  79. #define IN_CLASSB_NSHIFT    16
  80. #define IN_CLASSB_HOST        0x0000ffff
  81. #define IN_CLASSB_MAX        65536
  82.  
  83. #define IN_CLASSC(i)            (((long)(i) & 0xe0000000) == 0xc0000000)
  84. #define IN_CLASSC_NET        0xffffff00
  85. #define IN_CLASSC_NSHIFT    8
  86. #define IN_CLASSC_HOST        0x000000ff
  87.  
  88. #define IN_CLASSD(i)            (((long)(i) & 0xf0000000) == 0xe0000000)
  89. #define IN_MULTICAST(i)         IN_CLASSD(i)
  90.  
  91. #define IN_EXPERIMENTAL(i)      (((long)(i) & 0xe0000000) == 0xe0000000)
  92. #define IN_BADCLASS(i)          (((long)(i) & 0xf0000000) == 0xf0000000)
  93.  
  94. #define INADDR_ANY        (u_long)0x00000000
  95. #define INADDR_BROADCAST    (u_long)0xffffffff      /* must be masked */
  96. #ifndef KERNEL
  97. #define INADDR_NONE        0xffffffff        /* -1 return */
  98. #endif
  99.  
  100. #define IN_LOOPBACKNET        127            /* official! */
  101.  
  102. /*
  103.  * Socket address, internet style.
  104.  */
  105. #ifdef __AMITCP__
  106. struct sockaddr_in {
  107.     u_char    sin_len;
  108.     u_char    sin_family;
  109.     u_short sin_port;
  110.     struct    in_addr sin_addr;
  111.     char    sin_zero[8];
  112. };
  113. #else
  114. struct sockaddr_in {
  115.     short    sin_family;
  116.     u_short sin_port;
  117.     struct    in_addr sin_addr;
  118.     char    sin_zero[8];
  119. };
  120. #endif
  121.  
  122. /*
  123.  * Options for use with [gs]etsockopt at the IP level.
  124.  */
  125. #define IP_OPTIONS    1        /* set/get IP per-packet options */
  126.  
  127. #ifdef KERNEL
  128. extern    struct domain inetdomain;
  129. extern    struct protosw inetsw[];
  130. struct    in_addr in_makeaddr();
  131. u_long    in_netof(), in_lnaof();
  132. #endif
  133.  
  134. #ifdef __AMITCP__
  135. #ifndef ntohl
  136. #define ntohl(x)        (x)
  137. #define ntohs(x)        (x)
  138. #define htonl(x)        (x)
  139. #define htons(x)        (x)
  140.  
  141. #define NTOHL(x)        (x)
  142. #define NTOHS(x)        (x)
  143. #define HTONL(x)        (x)
  144. #define HTONS(x)        (x)
  145. #endif
  146.  
  147. /*
  148.  * Structure used to describe IP options.
  149.  * Used to store options internally, to pass them to a process,
  150.  * or to restore options retrieved earlier.
  151.  * The ip_dst is used for the first-hop gateway when using a source route
  152.  * (this gets put into the header proper).
  153.  */
  154. struct ip_opts {
  155.     struct    in_addr ip_dst;     /* first hop, 0 w/o src rt */
  156.     char    ip_opts[40];        /* actually variable in size */
  157. };
  158.  
  159. /*
  160.  * Options for use with [gs]etsockopt at the IP level.
  161.  * First word of comment is data type; bool is stored in int.
  162.  */
  163. #define IP_OPTIONS    1    /* buf/ip_opts; set/get IP per-packet options */
  164. #define IP_HDRINCL    2    /* int; header is included with data (raw) */
  165. #define IP_TOS        3    /* int; IP type of service and precedence */
  166. #define IP_TTL        4    /* int; IP time to live */
  167. #define IP_RECVOPTS    5    /* bool; receive all IP options w/datagram */
  168. #define IP_RECVRETOPTS    6    /* bool; receive IP options for response */
  169. #define IP_RECVDSTADDR    7    /* bool; receive IP dst addr w/datagram */
  170. #define IP_RETOPTS    8    /* ip_opts; set/get IP per-packet options */
  171. #endif
  172.  
  173. #endif
  174.